define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'userminer/index' + location.search,
                    // add_url: 'userminer/add',
                    // edit_url: 'userminer/edit',
                    del_url: 'userminer/del',
                    multi_url: 'userminer/multi',
                    table: 'user_miner',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('User_id')},
                        // {field: 'user.mobile', title: __('User.mobile')},
                        // {field: 'virtual_text', title: __('Virtual')},
                        {field: 'miner_id', title: __('Miner_id')},
                        {field: 'miner_cat', title: __('Miner_cat'), searchList: {"0":"-","1":__('Miner_cat 1'),"2":__('Miner_cat 2')}, formatter: Table.api.formatter.normal},
                        // {field: 'miner_type', title: __('Miner_type'), searchList: {"1":__('Miner_type 1'),"2":__('Miner_type 2'),"3":__('Miner_type 3')}, formatter: Table.api.formatter.normal},
                        // {field: 'output_value', title: __('Output_value'), operate:'BETWEEN'},
                        // {field: 'arithmetic_value', title: __('Arithmetic_value'), operate:'BETWEEN'},
                        // {field: 'sum_earnings', title: __('Sum_earnings'), operate:'BETWEEN'},
                        // {field: 'run_cycle', title: __('Run_cycle')},
                        {field: 'runed_cycle', title: __('Runed_cycle')},
                        // {field: 'output_limit', title: __('累计产矿')},
                        // {field: 'runed_cycle', title: __('Runed_cycle')},
                        {field: 'sum_output', title: __('已产矿')},
                        {field: 'price', title: __('Price'), operate:false},
                        // {field: 'active_price', title: '激活价', operate:false},
                        // {field: 'buy_type', title: __('Buy_type'), searchList: {"1":__('Buy_type 1'),"2":__('Buy_type 2'),"3":__('Buy_type 3'),"4":__('Buy_type 4')}, formatter: Table.api.formatter.normal},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'endtime', title: '结束时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});